package com.itheima.controller;

import com.itheima.domain.SmsFlashPromotion;
import com.itheima.manager.SmsFlashManager;
import com.itheima.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/flash")
public class SmsFlashController {

    @Autowired
    SmsFlashManager smsFlashManager;

    //秒杀活动分页查询
    @GetMapping("/list")
    public R findByPage(Integer pageNum,Integer pageSize,String keyword){
        return smsFlashManager.findByPage(pageNum,pageSize,keyword);
    }

    //修改秒杀活动上下线
    @PostMapping("/update/status/{id}")
    public R updateStatusById(@PathVariable Long id, Integer status){
        return smsFlashManager.updateStatusById(id,status);
    }

    //编辑秒杀活动
    @PostMapping("/update/{id}")
    public R updateById(@PathVariable Long id, @RequestBody SmsFlashPromotion smsFlashPromotion){
        return smsFlashManager.updateById(smsFlashPromotion);
    }

    //删除秒杀活动
    @PostMapping("/delete/{id}")
    public R deleteById(@PathVariable Long id){
        return smsFlashManager.deleteById(id);
    }
}
